<!DOCTYPE html>
<html >
<head >
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css"  media="all"/>
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/loader.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/openshow.css" media="all"/>
</head>
<style>
	html{
		background-color:#fff;
		height: 100%;
		border-bottom: 2px solid #f2f2f2;
		box-sizing: border-box;
	}
	.layui-input-block>p{line-height: 34px;}
	.table-box{margin-left:0;min-height:0;}
	.layui-table{display: none;}
</style>
<body>
<form class="layui-form">
 <div class="layui-form-item">
    <label class="layui-form-label">注文番号:</label>
    <div class="layui-input-block">
      <p class="orderNum"></p>
    </div>
  </div>
 <div class="layui-form-item">
    <label class="layui-form-label">注文時間:</label>
    <div class="layui-input-block">
      <p class="orderTime"></p>
    </div>
  </div>
 <div class="layui-form-item">
    <label class="layui-form-label">卓番:</label>
    <div class="layui-input-block">
      <p class="deskName"></p>
    </div>
  </div>
  <div class="layui-form-item">
  	<!-- 表格数据 -->
  	<script type="text/html" id="barDemo">
  		<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  	  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  	</script>
  	<div class="layui-input-block table-box">
  		<table  cellspacing="0" cellpadding="0" border="0" class="layui-table" id="tableList">
  			<thead><tr><th>メニュー</th><th>数量</th><th>金額</th></tr></thead>
  			<tbody></tbody>
  		</table>
  	</div>
  </div>
</form>
<script   src="../../../layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="../../../lib/jQuery-2.2.0.min.js" ></script>
<script>
	layui.config({
		base :  '../../../layuiadmin/' //静态资源所在路径
	}).extend({
		webplus : 'lib/webplus', //主入口模块
	}).use([ 'form','webplus' ], function() {
		var webplus=layui.webplus;
		var id = webplus.getUrlType().id;
		// 根据id拿到最新数据
		webplus.doAjax('buss/order/show',{id:id},'','',3,function(res){
				if(webplus.isEmpty(res.data)) return false;
				// 处理后的数据赋值
				$(".orderNum").text(id);
				$(".orderTime").text(res.data.orderTime);
				$(".deskName").text(res.data.deskName);
				var trHtml = '';
				// 遍历数据
				for(var i=0;i<res.data.dataList.length;i++){
					var data = res.data.dataList[i];
					var whetherTakeOut=data.whetherTakeOut;
					if(whetherTakeOut=='1'){
						trHtml += '<tr><td>'+data.menuName+'<span style="color:red" >*<span></td><td>'+data.buyNum+'</td><td style="width:120px">'+ webplus.number_format(data.menuSumPrice,0,"",",")+'</td></tr>';
					}else{
						trHtml += '<tr><td>'+data.menuName+'</td><td>'+data.buyNum+'</td><td style="width:120px">'+ webplus.number_format(data.menuSumPrice,0,"",",")+'</td></tr>';
					}
					
				}
				trHtml += '<tr><td>お通し</td><td>'+res.data.eatNum+'</td><td style="width:120px">'+ webplus.number_format(res.data.deskAmount,0,"",",")+'</td></tr>';
				//var smallTotallHtml = '<tr><td colspan="2">小計</td><td style="width:120px">'+webplus.number_format(res.data.smallTotalAmount,0)+'</td></tr>';
				var taxAmount= res.data.taxAmount;
				var taxPriceHtml='';
				if(taxAmount>0){
					
					taxPriceHtml= '<tr><td colspan="2">税金（10%）</td><td style="width:120px">'+webplus.number_format(taxAmount,0)+'</td></tr>';
				}
				var  outTaxAmount=res.data.outTaxAmount;
				var outTaxPriceHtml=''
				if(outTaxAmount>0){
					
					outTaxPriceHtml= '<tr><td colspan="2">税金（8%）</td><td style="width:120px">'+webplus.number_format(outTaxAmount,0)+'</td></tr>';
				}
				
				var totalHtml = '<tr><td colspan="2">合計</td><td style="width:120px">'+webplus.number_format(res.data.totalAmount,0)+'</td></tr>';
				$("#tableList>tbody").html(trHtml+taxPriceHtml+outTaxPriceHtml+totalHtml);
				$(".layui-table").show();
		});
		
		
	});
</script>
</body>
</html>